const express =  require('express');
const path = require('path');
const bodyParser = require('body-parser')
const lessMiddleware = require('less-middleware');
// require('bootstrap');

const app = express();

// 设置模板引擎
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');


app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json())
// 配置less中间件
app.use(lessMiddleware('/less', {
    dest: '/css',
    pathRoot: path.join(__dirname, 'public')
}));

// 设置公共资源文件夹
app.use(express.static(path.join(__dirname, 'public')));

// 路由
var mainRoutes = require('./routes/index');

app.use('/', mainRoutes);

app.listen(8081, ()=>{
    console.log('server is runing at 8080')
})